import React,{Component} from "react";
class DemosetState extends Component {
  state = { 
    count:0
   } 
   
  //  setState处在同步的逻辑中,异步更新状态,更新真实dom
  conlog=()=>{
    this.setState({
      count: this.state.count + 1
    })

    this.setState({
      count: this.state.count + 1
    })
    console.log('count=', this.state.count) // 0
    this.setState({
        count: this.state.count + 1
    })
    // console.log('===');
  }

  render() { 
    console.log('count=', this.state.count) // 0
    return (
      <div>
         <h2>08.setState同步异步</h2>
         count:{this.state.count}
         <button onClick={this.conlog}>count++</button>
      </div>
    );
  }
}
 
export default DemosetState;